<?php

class Alerts extends HTech_Db_Table
{
    protected $_name    = 'view_alerts';
    protected $_primary = 'AlertId';
    
    protected $_lnkTables = array('LnkAlertsRoles' => 'RoleId');
    
    protected function _setGridMetadata()
    {
        $this->_gridMetadata['title'] = $this->translate("Alerts");
        $this->_gridMetadata['onClick'] = 'admin.alert.view';
        $this->_gridMetadata['headers'] = array
            (
                array('AlertId',    50, $this->translate("Id"),       'Number'),
                array('ResourceId', 50, $this->translate("Resource"), 'Number'),
                array('Alert',     100, $this->translate("Alert"),    'String'),
                array('Life',       50, $this->translate("Life"),     'Number')
            );
        return $this;
    }
    
    protected function _setRecordDependentRows()
    {
        $this->_record->r = (object) array('roles' => null);
        $this->_record->r->roles = $this->_record->d->findManyToManyRowset('Roles','LnkAlertsRoles');   
        array_walk($this->_record->r->roles->toArray(), array($this, '_setRecordLnkData'), array('LnkAlertsRoles', 'RoleId'));   
    }
}